package org.compiere.model;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;

import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;

public class Mhrmmedicareline extends X_hrm_medicare_line {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7626048284604374289L;
	
	/**	Static Logger	*/
	private static CLogger	s_log	= CLogger.getCLogger (Mhrmmedicareline.class);

	public Mhrmmedicareline(Properties ctx) {
		super(ctx);
		// TODO Auto-generated constructor stub
	}
	
	public Mhrmmedicareline(Properties ctx, int hrm_medicare_line_ID,
			String trxName) {
		super(ctx, hrm_medicare_line_ID, trxName);
		// TODO Auto-generated constructor stub
	}
	
	public Mhrmmedicareline(Properties ctx, ResultSet rs, String trxName) {
		super(ctx, rs, trxName);
		// TODO Auto-generated constructor stub
	}

public static Mhrmmedicareline getMedicareRec(int C_BPartner_ID, int hrm_medicare_id) {
		
		//
	    PreparedStatement pstmt = null;
		ResultSet rs = null;
		Mhrmmedicareline medicareline = null;
			
		// 
			String sql_ = "SELECT * FROM HRM_MEDICARE_LINE \n " +
							"WHERE ISACTIVE='Y' \n " +
								"AND AD_CLIENT_ID=" + Env.getAD_Client_ID(Env.getCtx()) + " \n " +
								"AND C_BPARTNER_ID=" + C_BPartner_ID + " \n " +
								"AND HRM_MEDICARE_ID=" + hrm_medicare_id;
			try
			{
				pstmt = DB.prepareStatement(sql_,null);				
				rs = pstmt.executeQuery();	
				if(rs.next())
					medicareline = new Mhrmmedicareline(Env.getCtx(), rs, null);
			}
			catch (SQLException e)
			{
				s_log.log(Level.SEVERE, "product", e);
			}
			finally
			{
				DB.close(rs, pstmt);
				rs = null; pstmt = null;
			}
			
		return medicareline;
		
	}
}
